package cn.sc.summer.gateway.exception;

import cn.sc.summer.constant.enums.ExceptionTypeEnum;
import lombok.Getter;

/**
 * 接口:异常基础类
 *
 * @author a-xin
 * @date 2023/1/19 2:16 PM
 */
@Getter
public class BaseException extends RuntimeException {

    private static final long serialVersionUID = 1L;

    private final String message;
    private Integer code = 500;

    public BaseException(String message) {
        super(message);
        this.message = message;
    }

    public BaseException(String message, Throwable e) {
        super(message, e);
        this.message = message;
    }

    public BaseException(String message, Integer code) {
        super(message);
        this.message = message;
        this.code = code;
    }

    public BaseException(ExceptionTypeEnum exceptionTypeenum) {
        this(exceptionTypeenum.getMessage(), exceptionTypeenum.getCode());
    }

    public BaseException(ExceptionTypeEnum exceptionTypeenum, String message) {
        this(message, exceptionTypeenum.getCode());
    }

}

